Regex remove everything thats outside { }

Posted by wemakeweb on Stack Overflow See other posts from Stack Overflow or by wemakeweb
Published on 2010-05-20T09:33:59Z Indexed on 2010/05/20 10:10 UTC
Read the original article Hit count: 358

Filed under:

Regex to remove everything outside the { } for example:

before: |loader|1|2|3|4|5|6|7|8|9|{"data" : "some data" }

after: {"data" : "some data" }

with @Marcelo's regex this works but not if there are others {} inside the {} like here:

"|loader|1|2|3|4|5|6|7|8|9|
   {'data':  
       [ 
         {'data':'some data'}
       ],  
   }"

© Stack Overflow or respective owner

Related posts about regex